package com.ruoyi.mk.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mk.domain.MkQuotation;
import com.ruoyi.mk.service.IMkQuotationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 官网用户报价Controller
 * @author ruoyi
 * @date 2025-06-24
 */
@RestController
@RequestMapping("/system/quotation")
public class MkQuotationController extends BaseController {

    @Autowired
    private IMkQuotationService mkQuotationService;

    /**
     * 查询官网用户报价列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MkQuotation mkQuotation) {
        startPage();
        List<MkQuotation> list = mkQuotationService.selectMkQuotationList(mkQuotation);
        return getDataTable(list);
    }

    /**
     * 导出官网用户报价列表
     */
    @PreAuthorize("@ss.hasPermi('system:quotation:export')")
    @Log(title = "官网用户报价", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MkQuotation mkQuotation) {
        List<MkQuotation> list = mkQuotationService.selectMkQuotationList(mkQuotation);
        ExcelUtil<MkQuotation> util = new ExcelUtil<MkQuotation>(MkQuotation.class);
        util.exportExcel(response, list, "官网用户报价数据");
    }

    /**
     * 获取官网用户报价详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:quotation:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mkQuotationService.selectMkQuotationById(id));
    }

    /**
     * 新增官网用户报价
     */
//    @Log(title = "官网用户报价", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkQuotation mkQuotation) {
        return toAjax(mkQuotationService.insertMkQuotation(mkQuotation));
    }

    /**
     * 修改官网用户报价
     */
    @PreAuthorize("@ss.hasPermi('system:quotation:edit')")
    @Log(title = "官网用户报价", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkQuotation mkQuotation) {
        return toAjax(mkQuotationService.updateMkQuotation(mkQuotation));
    }

    /**
     * 删除官网用户报价
     */
    @PreAuthorize("@ss.hasPermi('system:quotation:remove')")
    @Log(title = "官网用户报价", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mkQuotationService.deleteMkQuotationByIds(ids));
    }
}
